package cn.xuexiyuan.flinkstudy.example;

import cn.xuexiyuan.flinkstudy.entity.Order;
import org.apache.flink.api.common.functions.AggregateFunction;

/**
 * @Description:
 * @Author 左龙龙
 * @Date 21-3-31
 * @Version 1.0
 **/
public class PriceAggregate implements AggregateFunction<Order, Integer, Integer> {
    @Override
    public Integer createAccumulator() {
        return 0;
    }

    @Override
    public Integer add(Order value, Integer accumulator) {
        return accumulator + value.getPayment_money();
    }

    @Override
    public Integer getResult(Integer accumulator) {
        return accumulator;
    }

    @Override
    public Integer merge(Integer a, Integer b) {
        return a + b;
    }
}
